package com.cloud.drore.eboss.supplier.mapper;

import com.cloud.drore.eboos.common.base.MyMapper;
import com.cloud.drore.eboss.supplier.entity.Product;
import com.cloud.drore.eboss.supplier.entity.TicketPriceSynchronization;
import com.cloud.drore.eboss.supplier.entity.TicketSynchronization;
import com.cloud.drore.eboss.supplier.entity.po.ProductInfoResponsePo;
import com.cloud.drore.eboss.supplier.entity.vo.ProductForFeeAndRefundFeeVo;
import com.cloud.drore.eboss.supplier.mapper.provider.ProductProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.UpdateProvider;

import java.util.Collection;
import java.util.List;


/**
 * 浙江卓锐科技股份有限公司 版权所有  Copyright 2018<br>
 *
 * @Description: <br>
 * @Project: eboos <br>
 * @CreateDate: Created in 2018/3/11 9:58 <br>
 * @Author: <a href="410508961@qq.com">夏凯</a>
 */
public interface ProductMapper extends MyMapper<Product> {
    //查询新插入的公共产品的数量
    @Select("select product_code,id from eboos_product order by id desc limit ${count}")
    List<Product> queryProductList(@Param("count") int count);
    //查询新插入的门票信息
    @Select("select product_code,id from eboos_ticket order by id desc limit ${count}")
    List<TicketPriceSynchronization> queryTicketList(@Param("count") int count);

    //批量进行修改产品
    @UpdateProvider(type = ProductProvider.class, method = "updateProduct")
    int updateProduct(String productString);
    //批量进行修改门票
    @UpdateProvider(type = ProductProvider.class, method = "updateTicket")
    int updateTicket(String productString);

    //批量更新product版
    @UpdateProvider(type = ProductProvider.class, method = "updateProductAll")
    void updateProductAll(@Param("list") Collection<ProductInfoResponsePo> configs);

    //批量更新ticket版
    @UpdateProvider(type = ProductProvider.class, method = "updateTicketAll")
    void updateTicketAll(@Param("list") Collection<ProductInfoResponsePo> configs);
    //批量更新ticketPrice版
    @UpdateProvider(type = ProductProvider.class, method = "updateTicketPrice")
    void updateTicketPrice(@Param("list") Collection<ProductInfoResponsePo> configs);
    //查询公共产品表的所有code的列表
    @Select("select product_code,id from eboos_product")
    List<Product> queryProductListForCode();

    //查询门票产品是否可退
    @Select("select fixed_rate,refund_model,can_refund,refund_fee,refund_one_day_ago,refund_two_days_ago,refund_three_days_ago " +
            "from eboos_ticket where common_product_id = ${id}")
    ProductForFeeAndRefundFeeVo queryTicketInfo(@Param("id") long id);

    //查询组合产品是否可退
    @Select("select fixed_rate,refund_model,can_refund,refund_fee,refund_one_day_ago,refund_two_days_ago,refund_three_days_ago " +
            "from eboos_combination_product where common_product_id = ${id}")
    ProductForFeeAndRefundFeeVo queryProductCombinationInfo(@Param("id") long id);


}